package tree;

public class MySolution {

    public static void main(String[] args){

        int sum = sum(3);
        System.out.println(sum);
    }


    /*public static int sum(int[] arr){
        int sum = sum(arr,0);
        return sum;
    }

    private static int sum(int[] arr,int index){

        if(index == arr.length){
            return 0;
        }

        int x = sum(arr,index+1);
        int sum = arr[index] + x;
        return sum;

    }*/

    public static int sum(int depth){
        return sum(depth,1);

    }

    private static int sum(int depth,int index){
        if(index > depth){
            return 0;
        }


        int x = sum(depth,index+1);
        int sum = index + x;
        return sum;
    }

}
